package com.yxe.controller;


import com.yxe.api.CommonResult;
import com.yxe.pojo.Expense;
import com.yxe.service.ExpenseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzq
 * @since 2022-12-09
 */
@RestController
@RequestMapping("/expense")
@Slf4j
@Api(tags = "首页费用")
public class ExpenseController {

    @Autowired
    private ExpenseService expenseService;

    @Resource
    private CommonResult<Object> commonResult;

    /**
     * 查询当前房间费用
     * @param id
     * @return
     */

    @GetMapping("findByUserId")
    @ApiOperation("显示当前费用")
    @ResponseBody
    public CommonResult<Expense> findByUserId(Integer id) {

        Expense expense = expenseService.findByUserId(id);

        if (expense != null) {
            return CommonResult.success(expense);
        } else {
            return CommonResult.failed();
        }

    }

}

